package com.bh.order.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bh.common.utils.DateUtils;
import com.bh.order.domain.JcLedReceivingParty;
import com.bh.order.dto.JcLedReceivingPartyVo;
import com.bh.order.mapper.JcLedReceivingpartyMapper;
import com.bh.order.service.IJcLedReceivingpartyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 分段订单收发货方Service业务层处理
 *
 * @author slx
 * @date 2023-04-24
 */

@Service
public class JcLedReceivingpartyServiceImpl extends ServiceImpl<JcLedReceivingpartyMapper, JcLedReceivingParty> implements IJcLedReceivingpartyService {
    @Autowired
    private JcLedReceivingpartyMapper jcLedReceivingpartyMapper;

    /**
     * 查询分段订单收发货方
     *
     * @param id 分段订单收发货方主键
     * @return 分段订单收发货方
     */
    @Override
    public JcLedReceivingParty selectJcLedReceivingpartyById(Long id) {
        return jcLedReceivingpartyMapper.selectById(id);
    }

    /**
     * 查询分段订单收发货方列表
     *
     * @param jcLedReceivingparty 分段订单收发货方
     * @return 分段订单收发货方
     */
    @Override
    public List<JcLedReceivingParty> selectJcLedReceivingpartyList(JcLedReceivingParty jcLedReceivingparty) {
        return jcLedReceivingpartyMapper.selectJcLedReceivingpartyList(jcLedReceivingparty);
    }

    @Override
    public List<JcLedReceivingParty> selectJcLedReceivingPartyListByLedId(Long ledId) {
        return jcLedReceivingpartyMapper.selectJcLedReceivingPartyListByLedId(ledId);
    }

    @Override
    public JcLedReceivingParty selectJcLedReceivingPartyListByLedIdAndType(Long ledId, String type) {
        return jcLedReceivingpartyMapper.selectJcLedReceivingPartyListByLedIdAndType(ledId, type);
    }

    /**
     * 新增分段订单收发货方
     *
     * @param jcLedReceivingparty 分段订单收发货方
     * @return 结果
     */
    @Override
    public int insertJcLedReceivingparty(JcLedReceivingParty jcLedReceivingparty) {
        jcLedReceivingparty.setCreateTime(DateUtils.getNowDate());
        return jcLedReceivingpartyMapper.insert(jcLedReceivingparty);
    }

    /**
     * 修改分段订单收发货方
     *
     * @param jcLedReceivingparty 分段订单收发货方
     * @return 结果
     */
    @Override
    public int updateJcLedReceivingparty(JcLedReceivingParty jcLedReceivingparty) {
        return jcLedReceivingpartyMapper.updateById(jcLedReceivingparty);
    }

    /**
     * 批量删除分段订单收发货方
     *
     * @param ids 需要删除的分段订单收发货方主键
     * @return 结果
     */
    @Override
    public int deleteJcLedReceivingpartyByIds(Long[] ids) {
        return jcLedReceivingpartyMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除分段订单收发货方信息
     *
     * @param id 分段订单收发货方主键
     * @return 结果
     */
    @Override
    public int deleteJcLedReceivingpartyById(Long id) {
        return jcLedReceivingpartyMapper.deleteById(id);
    }

    @Override
    public List<JcLedReceivingPartyVo> selectAddressInfo(Long shipmentId) {
        return jcLedReceivingpartyMapper.selectAddressInfo(shipmentId);
    }
}
